import { defineStore } from "pinia";
import { ref } from 'vue'

export const useMyUserInfoStore = defineStore('myUserInfo', () => {
  const userInfo = ref({})
  // 设置用户信息
  const setUserInfo = (info) => {
    userInfo.value = info
  }
  return { userInfo, setUserInfo }
}, {
  // 开启持久化 存储用户信息
  persist: {
    key: 'myUserInfo', // 存储的键名，默认是store的id
    storage: localStorage, // 存储方式，默认是localStorage
    paths: ['userInfo'] // 指定要持久化的状态路径
  }
})